/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class SearchInside
    {
    
        private Decimal? totalExcerptsField;

        private  SearchInsideExcerpt excerptField;

        /// <summary>
        /// Gets and sets the TotalExcerpts property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TotalExcerpts")]
        public Decimal TotalExcerpts
        {
            get { return this.totalExcerptsField.GetValueOrDefault() ; }
            set { this.totalExcerptsField= value; }
        }



        /// <summary>
        /// Sets the TotalExcerpts property
        /// </summary>
        /// <param name="totalExcerpts">TotalExcerpts property</param>
        /// <returns>this instance</returns>
        public SearchInside WithTotalExcerpts(Decimal totalExcerpts)
        {
            this.totalExcerptsField = totalExcerpts;
            return this;
        }



        /// <summary>
        /// Checks if TotalExcerpts property is set
        /// </summary>
        /// <returns>true if TotalExcerpts property is set</returns>
        public Boolean IsSetTotalExcerpts()
        {
            return  this.totalExcerptsField != null;

        }


        /// <summary>
        /// Gets and sets the Excerpt property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Excerpt")]
        public SearchInsideExcerpt Excerpt
        {
            get { return this.excerptField ; }
            set { this.excerptField = value; }
        }



        /// <summary>
        /// Sets the Excerpt property
        /// </summary>
        /// <param name="excerpt">Excerpt property</param>
        /// <returns>this instance</returns>
        public SearchInside WithExcerpt(SearchInsideExcerpt excerpt)
        {
            this.excerptField = excerpt;
            return this;
        }



        /// <summary>
        /// Checks if Excerpt property is set
        /// </summary>
        /// <returns>true if Excerpt property is set</returns>
        public Boolean IsSetExcerpt()
        {
            return this.excerptField != null;
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetTotalExcerpts()) {
                xml.Append("<TotalExcerpts>");
                xml.Append(this.TotalExcerpts);
                xml.Append("</TotalExcerpts>");
            }
            if (IsSetExcerpt()) {
                SearchInsideExcerpt  excerpt = this.Excerpt;
                xml.Append("<Excerpt>");
                xml.Append(excerpt.ToXMLFragment());
                xml.Append("</Excerpt>");
            } 
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}